// 蜂窝蜜造平台生成代码，如手工更改，请添加到 .beeignore 忽略生成
package com.fowo.api.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fowo.api.common.model.IdListPo;
import com.fowo.api.common.model.IdPo;
import com.fowo.api.common.model.ImportRow;
import com.fowo.api.common.model.OptionItem;
import com.fowo.api.common.model.R;
import com.fowo.api.common.util.ResponseUtils;
import com.fowo.api.entity.FBAInvoice;
import com.fowo.api.model.fbainvoice.FBAInvoiceImportPo;
import com.fowo.api.model.fbainvoice.FBAInvoiceItemVo;
import com.fowo.api.model.fbainvoice.FBAInvoiceSearchParamPo;
import com.fowo.api.model.fbainvoice.FBAInvoiceVo;
import com.fowo.api.service.FBAInvoiceService;
import com.fowo.api.sys.entity.SysFile;
import com.fowo.api.user.model.JwtUserInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.core.io.ClassPathResource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.StreamUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@Tag(name = "发货单")
@RequestMapping("/api/f-b-a-invoice")
@RestController
public class FBAInvoiceController {

  @Resource
  private FBAInvoiceService service;

  @Operation(summary = "查询结果")
  @GetMapping
  public R<List<FBAInvoiceItemVo>> search(FBAInvoiceSearchParamPo search) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.search(search));
  }

  @Operation(summary = "快速查询选项(有缓存)")
  @GetMapping("options")
  public R<List<OptionItem<FBAInvoiceItemVo>>> searchOptions(
    FBAInvoiceSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.searchOptions(search));
  }

  @Operation(summary = "查询最后更新时间")
  @GetMapping("lastUpdateTime")
  public R<Date> searchLastUpdateTime(FBAInvoiceSearchParamPo search) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.searchLastUpdateTime(search));
  }

  @Operation(summary = "获取分页查询结果")
  @GetMapping("page")
  public R<Page<FBAInvoiceItemVo>> getPage(FBAInvoiceSearchParamPo search) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.pageSearch(search));
  }

  @Operation(summary = "获取包括子表的查询结果")
  @GetMapping("page-with-child")
  public R<Page<?>> getPageWithChild(FBAInvoiceSearchParamPo search) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.pageWithChildSearch(search));
  }

  @Operation(summary = "仅获取子表的查询结果")
  @GetMapping("page-only-child/{parentId}")
  public R<Page<?>> getPageOnlyChild(
    @PathVariable Long parentId,
    FBAInvoiceSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.pageOnlyChildSearch(parentId, search));
  }

  @Operation(summary = "查询是否后台下载")
  @GetMapping("getBackgroundExportFlag")
  public R<Boolean> getBackgroundExportFlag(FBAInvoiceSearchParamPo search) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.getBackgroundExportFlag(search));
  }

  @Operation(summary = "获取详情")
  @GetMapping("{id}")
  public R<FBAInvoiceVo> getVoById(@PathVariable Long id) {
    return R.data(() -> service.getVoById(id));
  }

  @Operation(summary = "获取物流商相关的编号列表")
  @GetMapping("logistics-provider/{texts}/ids")
  public R<List<Long>> getIdsByLogisticsProvider(@PathVariable String texts) {
    List<String> nameList = Arrays
      .stream(texts.split(","))
      .collect(Collectors.toList());
    return R.data(() -> service.getIdsByLogisticsProvider(nameList));
  }

  @Operation(summary = "获取编号相关的物流商列表")
  @GetMapping("logistics-provider/{ids}")
  public R<List<String>> getVoById(@PathVariable String ids) {
    List<Long> idList = Arrays
      .asList(ids.split(","))
      .stream()
      .map(Long::valueOf)
      .collect(Collectors.toList());
    return R.data(() -> service.getLogisticsProviderByIds(idList));
  }

  @PreAuthorize("@am.canAccess('fBAInvoiceCreate')")
  @Operation(summary = "新增")
  @PostMapping
  public R<Long> create(@Validated @RequestBody FBAInvoiceVo model) {
    return R.data(() -> service.create(model));
  }

  @PreAuthorize("@am.canAccess('fBAInvoiceEdit')")
  @Operation(summary = "更新")
  @PutMapping
  public R update(@RequestBody FBAInvoiceVo model) {
    return R.run(() -> service.update(model));
  }

  @PreAuthorize("@am.canAccess('fBAInvoiceEdit')")
  @Operation(summary = "编辑更新")
  @PutMapping("edit")
  public R updateForEdit(@RequestBody FBAInvoiceVo model) {
    return R.run(() -> service.updateForEdit(model));
  }

  @PreAuthorize("@am.canAccess('fBAInvoiceDelete')")
  @Operation(summary = "删除")
  @DeleteMapping("{id}")
  public R delete(@PathVariable Long id) {
    return R.run(() -> service.delete(id));
  }

  @PreAuthorize("@am.canAccess('fBAInvoiceDelete')")
  @Operation(summary = "批量删除")
  @DeleteMapping("batch")
  public R batchDelete(@RequestBody IdListPo po) {
    return R.run(() -> service.batchDelete(po.getIds()));
  }

  @PreAuthorize("@am.canAccess('fBAInvoiceImport')")
  @Operation(summary = "导入预览")
  @PostMapping("import-preview")
  public R<List<ImportRow<FBAInvoiceImportPo>>> importPreview(
    @RequestBody SysFile sysFile,
    @RequestParam(name = "template", required = false) Long templateId,
    @RequestParam(
      name = "allowOverrides",
      defaultValue = "false"
    ) boolean allowOverrides
  ) {
    return R.data(() ->
      service.importPreview(sysFile, templateId, allowOverrides)
    );
  }

  @PreAuthorize("@am.canAccess('fBAInvoiceImport')")
  @Operation(summary = "完成导入")
  @PostMapping("import-done")
  public R importDone(
    @RequestBody List<ImportRow<FBAInvoiceImportPo>> rows,
    @RequestParam(name = "template", required = false) Long templateId
  ) {
    return R.run(() -> service.importDone(rows, templateId));
  }

  @Operation(summary = "下载导入模版")
  @GetMapping("import/template")
  public void downloadImportTemplate(HttpServletResponse response)
    throws IOException {
    ResponseUtils.setAttachmentFileName(response, "发货单导入模版.xlsx");
    InputStream inputStream = new ClassPathResource("templates/FBAInvoice.xlsx")
      .getInputStream();
    StreamUtils.copy(inputStream, response.getOutputStream());
  }

  @Operation(summary = "导出")
  @GetMapping("export")
  @PreAuthorize("@am.canAccess('fBAInvoiceExport')")
  public void export(
    @RequestParam(name = "template", required = false) Long templateId,
    FBAInvoiceSearchParamPo search,
    HttpServletResponse response
  ) throws Exception {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    service.export(templateId, search, response);
  }

  @PreAuthorize("@am.canAccess('fBAInvoiceMarkLocked')")
  @Operation(summary = "标记已锁库")
  @PostMapping("markLocked")
  public R markLocked(@RequestBody IdListPo po) {
    return R.run(() -> service.markLocked(po.getIds()));
  }

  @PreAuthorize("@am.canAccess('fBAInvoiceReleaseInventory')")
  @Operation(summary = "释放库存")
  @PostMapping("releaseInventory")
  public R releaseInventory(@RequestBody IdListPo po) {
    return R.run(() -> service.releaseInventory(po.getIds()));
  }

  @PreAuthorize("@am.canAccess('fBAInvoiceLockinventory')")
  @Operation(summary = "锁库存")
  @PostMapping("lockinventory")
  public R lockinventory(@RequestBody IdListPo po) {
    return R.run(() -> service.lockinventory(po.getIds()));
  }

  @PreAuthorize("@am.canAccess('fBAInvoicePushStockOut')")
  @Operation(summary = "推送出库单")
  @PostMapping("pushStockOut")
  public R pushStockOut(@RequestBody IdListPo po) {
    return R.run(() -> service.pushStockOut(po.getIds()));
  }

  @PreAuthorize("@am.canAccess('fBAInvoiceSyncData')")
  @Operation(summary = "同步数据")
  @PostMapping("syncData")
  public R syncData() {
    return R.run(() -> service.syncData());
  }

  @PreAuthorize("@am.canAccess('fBAInvoiceFinishPicking')")
  @Operation(summary = "完成拣货")
  @PostMapping("finishPicking")
  public R finishPicking(@RequestBody IdListPo po) {
    return R.run(() -> service.finishPicking(po.getIds()));
  }

  @PreAuthorize("@am.canAccess('fBAInvoiceFinishPickingInventory')")
  @Operation(summary = "拣货即时库存")
  @PostMapping("finishPickingInventory")
  public R finishPickingInventory(@RequestBody IdListPo idListPo) {
    return R.run(() -> service.finishPickingInventory(idListPo.getIds()));
  }

  @PreAuthorize("@am.canAccess('fBAInvoiceFinishPickingBingId')")
  @Operation(summary = "拣货仓位")
  @PostMapping("finishPickingBingId")
  public R finishPickingBingId(@RequestBody IdListPo idListPo) {
    return R.run(() -> service.finishPickingBingId(idListPo.getIds()));
  }

  @PreAuthorize("@am.canAccess('fBAInvoiceShippingOut')")
  @Operation(summary = "发货出库")
  @PostMapping("shippingOut")
  public R shippingOut(@RequestBody IdListPo idListPo) {
    return R.run(() -> service.shippingOut(idListPo.getIds()));
  }

  @PreAuthorize("@am.canAccess('fBAInvoiceShipping')")
  @Operation(summary = "发货")
  @PostMapping("shipping")
  public R shipping(@RequestBody IdListPo po) {
    return R.run(() -> service.shipping(po.getIds()));
  }

  @PreAuthorize("@am.canAccess('fBAInvoiceAllocateInventory')")
  @Operation(summary = "分配库存")
  @PostMapping("allocateInventory")
  public R allocateInventory(@RequestBody IdListPo po) {
    return R.run(() -> service.allocateInventory(po.getIds()));
  }

  @PreAuthorize("@am.canAccess('fBAInvoiceMarkasshipped')")
  @Operation(summary = "标记已发货")
  @PostMapping("markasshipped")
  public R markasshipped(@RequestBody IdListPo po) {
    return R.run(() -> service.markasshipped(po.getIds()));
  }

  @PreAuthorize("@am.canAccess('fBAInvoiceLocksInventory')")
  @Operation(summary = "锁库存_即时")
  @PostMapping("locksInventory")
  public R locksInventory(@RequestBody IdPo idPo) {
    return R.run(() -> service.locksInventory(idPo.getId()));
  }

  @PreAuthorize("@am.canAccess('fBAInvoiceLockpInventory')")
  @Operation(summary = "锁库存_仓位")
  @PostMapping("lockpInventory")
  public R lockpInventory(@RequestBody IdPo idPo) {
    return R.run(() -> service.lockpInventory(idPo.getId()));
  }

  @PreAuthorize("@am.canAccess('fBAInvoiceCancelLocksInventory')")
  @Operation(summary = "取消锁库存_即时")
  @PostMapping("cancelLocksInventory")
  public R cancelLocksInventory(@RequestBody IdPo idPo) {
    return R.run(() -> service.cancelLocksInventory(idPo.getId()));
  }

  @PreAuthorize("@am.canAccess('fBAInvoiceCancelLockpInventory')")
  @Operation(summary = "取消锁库存_仓位")
  @PostMapping("cancelLockpInventory")
  public R cancelLockpInventory(@RequestBody IdPo idPo) {
    return R.run(() -> service.cancelLockpInventory(idPo.getId()));
  }

  @PreAuthorize("@am.canAccess('fBAInvoiceLockStockOut')")
  @Operation(summary = "出库锁定")
  @PostMapping("lockStockOut")
  public R lockStockOut(@RequestBody IdPo idPo) {
    return R.run(() -> service.lockStockOut(idPo.getId()));
  }

  /**
   * 视图选项卡标题上显示计数
   */
  @Operation(summary = "视图选项卡标题上显示计数")
  @GetMapping("getTabHeaderShowTotal")
  public R<Map> getTabHeaderShowTotal() {
    return R.data(() -> service.getTabHeaderShowTotal());
  }

  @Operation(summary = "全部")
  @GetMapping("f-b-a-invoice-all-view")
  public R<List<FBAInvoiceItemVo>> fBAInvoiceAllView(
    FBAInvoiceSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.fBAInvoiceAllView(search));
  }

  @Operation(summary = "全部分页")
  @GetMapping("f-b-a-invoice-all-viewPage")
  public R<Page<FBAInvoiceItemVo>> fBAInvoiceAllViewPage(
    FBAInvoiceSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.fBAInvoiceAllViewPage(search));
  }

  @Operation(summary = "全部包括子表的查询结果")
  @GetMapping("f-b-a-invoice-all-viewPage-with-child")
  public R<Page<?>> fBAInvoiceAllViewPageWithChild(
    FBAInvoiceSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.fBAInvoiceAllViewPageWithChildSearch(search));
  }

  @Operation(summary = "全部最后更新时间")
  @GetMapping("f-b-a-invoice-all-viewLastUpdateTime")
  public R<Date> fBAInvoiceAllViewLastUpdateTime(
    FBAInvoiceSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.fBAInvoiceAllViewLastUpdateTime(search));
  }

  @Operation(summary = "待配货")
  @GetMapping("f-b-a-invoice-distributed-view")
  public R<List<FBAInvoiceItemVo>> fBAInvoiceDistributedView(
    FBAInvoiceSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.fBAInvoiceDistributedView(search));
  }

  @Operation(summary = "待配货分页")
  @GetMapping("f-b-a-invoice-distributed-viewPage")
  public R<Page<FBAInvoiceItemVo>> fBAInvoiceDistributedViewPage(
    FBAInvoiceSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.fBAInvoiceDistributedViewPage(search));
  }

  @Operation(summary = "待配货包括子表的查询结果")
  @GetMapping("f-b-a-invoice-distributed-viewPage-with-child")
  public R<Page<?>> fBAInvoiceDistributedViewPageWithChild(
    FBAInvoiceSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.fBAInvoiceDistributedViewPageWithChildSearch(search));
  }

  @Operation(summary = "待配货最后更新时间")
  @GetMapping("f-b-a-invoice-distributed-viewLastUpdateTime")
  public R<Date> fBAInvoiceDistributedViewLastUpdateTime(
    FBAInvoiceSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.fBAInvoiceDistributedViewLastUpdateTime(search)
    );
  }

  @Operation(summary = "待发货")
  @GetMapping("f-b-a-invoice-send-view")
  public R<List<FBAInvoiceItemVo>> fBAInvoiceSendView(
    FBAInvoiceSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.fBAInvoiceSendView(search));
  }

  @Operation(summary = "待发货分页")
  @GetMapping("f-b-a-invoice-send-viewPage")
  public R<Page<FBAInvoiceItemVo>> fBAInvoiceSendViewPage(
    FBAInvoiceSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.fBAInvoiceSendViewPage(search));
  }

  @Operation(summary = "待发货包括子表的查询结果")
  @GetMapping("f-b-a-invoice-send-viewPage-with-child")
  public R<Page<?>> fBAInvoiceSendViewPageWithChild(
    FBAInvoiceSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.fBAInvoiceSendViewPageWithChildSearch(search));
  }

  @Operation(summary = "待发货最后更新时间")
  @GetMapping("f-b-a-invoice-send-viewLastUpdateTime")
  public R<Date> fBAInvoiceSendViewLastUpdateTime(
    FBAInvoiceSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.fBAInvoiceSendViewLastUpdateTime(search));
  }

  @Operation(summary = "已发货")
  @GetMapping("f-b-a-invoice-has-send-view")
  public R<List<FBAInvoiceItemVo>> fBAInvoiceHasSendView(
    FBAInvoiceSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.fBAInvoiceHasSendView(search));
  }

  @Operation(summary = "已发货分页")
  @GetMapping("f-b-a-invoice-has-send-viewPage")
  public R<Page<FBAInvoiceItemVo>> fBAInvoiceHasSendViewPage(
    FBAInvoiceSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.fBAInvoiceHasSendViewPage(search));
  }

  @Operation(summary = "已发货包括子表的查询结果")
  @GetMapping("f-b-a-invoice-has-send-viewPage-with-child")
  public R<Page<?>> fBAInvoiceHasSendViewPageWithChild(
    FBAInvoiceSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.fBAInvoiceHasSendViewPageWithChildSearch(search));
  }

  @Operation(summary = "已发货最后更新时间")
  @GetMapping("f-b-a-invoice-has-send-viewLastUpdateTime")
  public R<Date> fBAInvoiceHasSendViewLastUpdateTime(
    FBAInvoiceSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.fBAInvoiceHasSendViewLastUpdateTime(search));
  }

  @Operation(summary = "已作废")
  @GetMapping("f-b-a-invoice-cancel-view")
  public R<List<FBAInvoiceItemVo>> fBAInvoiceCancelView(
    FBAInvoiceSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.fBAInvoiceCancelView(search));
  }

  @Operation(summary = "已作废分页")
  @GetMapping("f-b-a-invoice-cancel-viewPage")
  public R<Page<FBAInvoiceItemVo>> fBAInvoiceCancelViewPage(
    FBAInvoiceSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.fBAInvoiceCancelViewPage(search));
  }

  @Operation(summary = "已作废包括子表的查询结果")
  @GetMapping("f-b-a-invoice-cancel-viewPage-with-child")
  public R<Page<?>> fBAInvoiceCancelViewPageWithChild(
    FBAInvoiceSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.fBAInvoiceCancelViewPageWithChildSearch(search));
  }

  @Operation(summary = "已作废最后更新时间")
  @GetMapping("f-b-a-invoice-cancel-viewLastUpdateTime")
  public R<Date> fBAInvoiceCancelViewLastUpdateTime(
    FBAInvoiceSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.fBAInvoiceCancelViewLastUpdateTime(search));
  }
}
